package com.jimikongjian.controller;

import com.jimikongjian.models.ResponseMessage;
import com.jimikongjian.models.Upvote;
import com.jimikongjian.service.base.IUpvoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * Created by fuxiuyang on 17/3/14.
 */
@RestController("upvoteController")
@RequestMapping(value = "/v1")
public class UpvoteController {

    @Autowired
    @Qualifier("upvoteService")
    private IUpvoteService upvoteService;

    /**
     * 收藏一篇文章
     * @param upvote
     * @return
     */
    @RequestMapping(value = "/upvote", method = RequestMethod.POST)
    @ResponseBody
    public ResponseMessage upvoteArticle(@RequestBody Upvote upvote){
        return upvoteService.upvoteArticle(upvote);
    }

    /**
     * 取消某一个收藏
     * @param upvote
     * @return
     */
    @RequestMapping(value = "/upvote", method = RequestMethod.PUT)
    @ResponseBody
    public ResponseMessage deleteUpvote(@RequestBody Upvote upvote){
        return upvoteService.deleteUpvote(upvote);
    }
}
